package leecode;

import java.util.List;

/**
 * 第十二天
 */
//第一题
public class Leetcode9 {
    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        ListNode head=new ListNode();
        ListNode cur=head;
        while (l1!=null&&l2!=null){
            if(head==null){
                if(l1.val>l2.val){
                    head=l2;
                    l2=l2.next;
                }else {
                    head=l1;
                    l1=l1.next;
                }
            }
            if(l1.val>l2.val){
                head.next=l2;
                head=head.next;
                l2=l2.next;
            }else {
                head.next=l1;
                head=head.next;
                l1=l1.next;
            }
        }
        while (l1!=null){
            head.next=l1;
            head=head.next;
            l1=l1.next;
        }
        while (l2!=null){
            head.next=l2;
            head=head.next;
            l2=l2.next;
        }
        return cur.next;
    }
//第二题
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
    ListNode cur1=headA;
    ListNode cur2=headB;
    int count1=0;
    int count2=0;
    while (cur1!=null){
        cur1=cur1.next;
        count1++;
    }
    while (cur2!=null){
        cur2=cur2.next;
        count2++;
    }
    int k=Math.abs(count1-count2);
    if(count1>count2){
        while (k-->0){
            headA=headA.next;
        }
    }else {
        while (k-->0){
            headB=headB.next;
        }
    }
    while (headA.next!=headB.next){
        headA=headA.next;
        headB=headB.next;
    }
    return headA.next;
}
    public enum hello{

        UNKNOWN_ERROR(1, "基本业务未知异常!");
        int i;
        String s;
        hello(int i, String s) {
        }

        /**
         * get field
         *
         * @return i
         */
        public int getI() {
            return this.i;
        }

        /**
         * set field
         *
         * @param i
         */
        public void setI(int i) {
            this.i = i;
        }

        /**
         * get field
         *
         * @return s
         */
        public String getS() {
            return this.s;
        }

        /**
         * set field
         *
         * @param s
         */
        public void setS(String s) {
            this.s = s;
        }
    }
    public static void main(String[] args) {

        System.out.println(hello.UNKNOWN_ERROR.getS());
    }
}
